import java.security.Policy;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo_ThreadPoolExecutor {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
                5,
                10,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(100),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy()
        );

        for(int i = 0; i < 1000; i++){
            int id = i;
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    System.out.println("task-" + (id + 1));
                }
            };
            threadPool.submit(runnable);
        }
    }
}
